home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz)
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 19 Mar 1996 22:29:12 -0600
- Organization: TU Wien
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4io1io$no4@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4iemcl$a05@solutions.solon.com>, stanr@tiac.net (Stan Ryckman) writes:
-
- |>if (*argv[ii] == '-')
- |>
- |> Ugh! If I were going to mix operators that way I'd use parens.
- |>
- |> Why not just write
- |> if (argv[ii][0] == '-') ...
- |> and then you won't have to worry what "*argv[ii]" is?
-
- Because you know that argv[ii][0] is really *argv[ii]?
-
- I've used several programming languages; each had its strengths and
- weaknesses. Exploiting a language's strengths gave rise to a certain
- programming style; doing things against the grain usually ended in
- cramps. One of C's most defining attributes is the pointer concept
- which includes the mapping of arrays to pointer arithmetic. If you're
- going to fight it, it might be better to switch to some other programming
- language.
-
- I recently wrote a loop that went like this:
-
- while (p < end_p)
- ++*p++;
-
- Maybe some will find it a counter-example; I think it's good
- code that embodies the way C is designed to work. Arrays are
- second rate objects in C. Use pointers.
-
- Konrad Schwarz
-